<?php

namespace App\Listeners\OpenShop;

use App\Events\OpenShop\ShopCreatedEvent;
use App\Library\FeiShu\SendFs;
use App\Listeners\BaseListener;
use App\Models\OpenShop\InvestmentPromotion\OpenShopSignOrderModel;
use App\Models\OpenShop\InvestmentPromotion\OpenShopUserIdentityCardModel;
use App\Service\OpenShop\Feishu\ShopManualService;

class CreateShopManualListener extends BaseListener
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    // 生成门店手册，不影响后续逻辑，无脑异步处理
    public function viaConnection()
    {
        return 'redis';
    }

    /**
     * Handle the event.
     *
     * @param ShopCreatedEvent $event
     * @return void
     */
    public function handle(ShopCreatedEvent $event)
    {
        // 判断是否存在
        $count = OpenShopSignOrderModel::getDataByShopCode($event->shopCode)->count();
        if ($count == 1) {
            (new ShopManualService($event->orderNo))->make($event->shopCode);
        }
    }
}
